import React from 'react';
import ReactDom from 'react-dom';

/**
 * react state
 */

class Clock extends React.Component {
  state={date: new Date()}
  componentDidMount(){
    setInterval(()=>{
      this.setState({date: new Date()})
    },1000)
  }
  render(){
    return <div>
      <h1>Hello World</h1>
      <div>当前时间{this.state.date.toLocaleTimeString()}</div>
    </div> 
  }
} 
let element = <Clock/>;
ReactDom.render(
  element,
  document.getElementById('root')
)
